package cn.javaxxw.springboot.actuator;

import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.stereotype.Component;

/**
 * @description TODO
 * @author trazen
 * @date 2022/9/5 21:42
 */
@Component("myHealthIndicator1")
public class MyHealthIndicator1 implements HealthIndicator {
    private static final String VERSION = "V1.0.0";

    @Override
    public Health health() {
        int code = check();
        if (code != 0) {
            Health.down().withDetail("code", code).withDetail("version", VERSION).build();
        }
        return Health.up().withDetail("code", code)
                .withDetail("version", VERSION).up().build();
    }
    private int check() {
        //实际业务场景中可以用来检查业务是否正常
        return 0;
    }
}
